package com.giaothong.http;

import org.json.JSONObject;

import android.content.Context;

import com.giaothong.config.ServerUrl;
import com.giaothong.http.core.HttpAsyncCallback;
import com.giaothong.http.core.HttpConnectionId;
import com.giaothong.http.core.NewHttpConnectionAsync;
import com.giaothong.model.entity.UserEntity;
import com.giaothong.utils.ALog;

public class HttpRegisterRequest extends NewHttpConnectionAsync {

	public HttpRegisterRequest(Context context, HttpAsyncCallback<JSONObject> callback) {
		super(context, HttpConnectionId.REGISTER_REQUEST, callback);
	}

	/**
	 * Call this func to request to server
	 * 
	 * @param pram1
	 * @param param2
	 */
	public void request(String userName, String password, String name, String address, String email, String phoneNumber) {
		// Create json object with data
		rootObj = new JSONObject();

		addParam("user_name", "" + userName);
		addParam("password", password);
		addParam("name", name);
		addParam("address", address);
		addParam("email", email);
		addParam("phone_number", phoneNumber);
		addParam("type", UserEntity.NORNAL_USER);

		// executable request
		ALog.i("Requests", ServerUrl.REGISTER + "___" + rootObj.toString());
		this.execute(ServerUrl.REGISTER);
	}

}
